package com.tac.controller.mes;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.mes.ProductionPlan;
import com.tac.service.mes.ProductionPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/productionPlan")
@Api(tags = "制造执行MES--生产计划")
@CrossOrigin
public class ProductionPlanController {

    @Autowired
    private ProductionPlanService productionPlanService;

    //查看生产计划
    @ApiOperation("查看生产计划")
    @GetMapping("/getList")
    public Result<PageInfo<ProductionPlan>> getList(Integer pageNum, Integer pageSize,
                                                    String project, String planNumber, String name, @DateTimeFormat(pattern = "yyyy-MM-dd") Date deliveryDateStart,@DateTimeFormat(pattern = "yyyy-MM-dd") Date deliveryDateEnd, String applicant,
                                                    @DateTimeFormat(pattern = "yyyy-MM-dd")Date applicantDateStart, @DateTimeFormat(pattern = "yyyy-MM-dd")Date applicantDateEnd, String applicantStatus, String auditor, @DateTimeFormat(pattern = "yyyy-MM-dd")Date examineDateStart,
                                                    @DateTimeFormat(pattern = "yyyy-MM-dd")Date examineDateEnd, String examineStatus
    ){
       return productionPlanService.getList(pageNum,pageSize,project,planNumber,name,deliveryDateStart,deliveryDateEnd,applicant,applicantDateStart,applicantDateEnd,applicantStatus,auditor,examineDateStart,examineDateEnd,examineStatus);
    }
    @ApiOperation("添加生产计划")
    //添加生产计划
    @PostMapping("/save")
    public Result save(@RequestBody ProductionPlan productionPlan){
        return productionPlanService.save(productionPlan);
    }
    //删除生产计划
    @ApiOperation("删除生产计划")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody List<Integer> ids){
        return productionPlanService.remove(ids);
    }
    //更新生产计划
    @ApiOperation("更新生产计划")
    @PutMapping("/update")
    public Result update(@RequestBody ProductionPlan productionPlan){
        return productionPlanService.update(productionPlan);
    }

    //管理员修改审核信息
    @ApiOperation("管理员修改审核信息")
    @PutMapping("/updateExamine")
    public Result updateExamine(@RequestBody ProductionPlan productionPlan){
        return productionPlanService.updateExamine(productionPlan);
    }

}
